package com.ywy.controller.admin;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 管理后台页面导航Controller
 *
 * @author ywy
 * @date 2022/9/1 10:08
 */
@Controller
@RequestMapping("admin")
public class AdminIndexController {
    /**
     * 跳转到管理员主页面
     *
     * @return
     */
    @RequiresPermissions(value = {"ADMIN"})
    @RequestMapping("")
    public ModelAndView index() {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("admin/index");
        return mav;
    }

    /**
     * 跳转到页面
     * @param pageName
     * @return
     */
    @RequestMapping("{pageName}.html")
    public ModelAndView toPage(@PathVariable("pageName") String pageName) {
        ModelAndView mav = new ModelAndView();
        if ("default".equals(pageName)) {
            mav.setViewName("admin/default");
        } else {
            mav.setViewName("admin/" + pageName + "/list");
        }
        return mav;
    }
}
